#!/bin/bash


echo "//****Ejecutando launcher de $1****\\\\"

cd ../out/host # hosts
./launcher_host 

cd ../../ #tp

./create_config.sh $2

for line in $(cat "./launcher_config/$1.conf"); do 
	echo "-ejecutando $line"
	case $line in
		"ADP")
			#lanzar los ipcs necesarios para el adp
			./out/launcher_adp
			lanzar="./out/adp=adp_pc"
			lxterminal -t "$line" -e "./launcher_config/keeper.sh $lanzar"
		;;"ADPT")
			./out/launcher_adpt
			lanzar="./out/adpt"
			lxterminal -t "$line" -e "./launcher_config/keeper.sh $lanzar"

		;;"AGV")
			./out/launcher_agv
			lanzar="./out/agv=izq=agv_pc"
			lxterminal -t "$line IZQ" -e "./launcher_config/keeper.sh $lanzar"
			lanzar="./out/agv=med=agv_pc"
			lxterminal -t "$line MED" -e "./launcher_config/keeper.sh $lanzar"
			lanzar="./out/agv=der=agv_pc"
			lxterminal -t "$line DER" -e "./launcher_config/keeper.sh $lanzar"
				
		;;"DESPACHO")

		;;"ROBOT11")
			./out/launcher_robot11
			lanzar="./out/robot11=izq=robot11_pc"
			lxterminal -t "$line IZQ" -e "./launcher_config/keeper.sh $lanzar"
			lanzar="./out/robot11=der=robot11_pc"
			lxterminal -t "$line DER" -e "./launcher_config/keeper.sh $lanzar"
				
		;;"ROBOT12")
			./out/launcher_robot12
			lanzar="./out/robot12=izq=robot12_pc"
			lxterminal -t "$line IZQ" -e "./launcher_config/keeper.sh $lanzar"
			lanzar="./out/robot12=der=robot12_pc"
			lxterminal -t "$line DER" -e "./launcher_config/keeper.sh $lanzar"

		;;"ROBOT14")
			cd out/host
			./launcher_robot14
			lanzar="./controlR14"
			lxterminal -t "$line" -e "./launcher_config/keeper.sh $lanzar"
			cd ../../

		;;"VENDEDOR")
			./out/launcher_vendedor
			lanzar="./out/vendedor"
			lxterminal -t "$line" -e "./launcher_config/keeper.sh $lanzar"

		;;"ROBOT16")

		;;"ROBOT5")
			./out/launcher_robot5
			lanzar="./out/robot5=robot5_pc"
			lxterminal -t "$line" -e "./launcher_config/keeper.sh $lanzar" &

		;;"")
		;;"")
		;;"")
		;;"")
				
	esac
done
